<!----------------------------------------------------
ページ名：Timetable.jsp
所　　属：H3A1 04
名　　前：大瀬碩
説　　明：時間割を表示するページ
------------------------------------------------------>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.util.Properties"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<title>確認</title>
</head>
<body>
<%
//ログイン状態に応じたナビゲーションバー
HttpSession ses = request.getSession(true); 

Object login = ses.getAttribute("login");

if("OK".equals(login)){
	out.print("<div class=\"navbar navbar-default\">");
	out.print("<div class=\"navbar-header\">");
	out.print("<button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">");
	out.print("<span class=\"icon-bar\"></span>");
	out.print("<span class=\"icon-bar\"></span>");
	out.print("<span class=\"icon-bar\"></span>");
	out.print("</button>");
	out.print("<a class=\"navbar-brand\" href=\"index.jsp\"><img src=\"images/logo2.png\"></a>");
	out.print("</div>");
	out.print("<div class=\"navbar-collapse collapse\">");
	out.print("<ul class=\"nav navbar-nav\">");
	out.print("<li class=\"active\"><a href=\"TimetableClassSelection.jsp\">時間割情報</a></li>");
	out.print("<li><a href=\"ClubList.jsp\">部活動情報</a></li>");
	out.print("<li><a href=\"SupplementaryClasses.jsp\">振り替え補講</a></li>");
	out.print("<li><a href=\"HolidayAttendance.jsp\">土日出校申請</a></li>");
	out.print("<li><a href=\"AttendanceHistory.jsp\">出席履歴</a></li>");
	out.print("</ul>");
	out.print("<ul class=\"nav navbar-nav navbar-right\">");
	out.print("<li><a href=\""+request.getContextPath()+"/Logout\">ログアウト</a></li>");
	out.print("</ul>");
	out.print("</div>");
	out.print("</div>");
}else{
	out.print("<div class=\"navbar navbar-default\">");
	out.print("<div class=\"navbar-header\">");
	out.print("<button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">");
	out.print("<span class=\"icon-bar\"></span>");
	out.print("<span class=\"icon-bar\"></span>");
	out.print("<span class=\"icon-bar\"></span>");
	out.print("</button>");
	out.print("<a class=\"navbar-brand\" href=\"index.jsp\"><img src=\"images/logo2.png\"></a>");
	out.print("</div>");
	out.print("<div class=\"navbar-collapse collapse\">");
	out.print("<ul class=\"nav navbar-nav\">");
	out.print("<li class=\"active\"><a href=\"TimetableClassSelection.jsp\">時間割情報</a></li>");
	out.print("<li><a href=\"ClubList.jsp\">部活動情報</a></li>");
	out.print("</ul>");
	out.print("<ul class=\"nav navbar-nav navbar-right\">");
	out.print("<li><a href=\"Login.jsp\">ログイン</a></li>");
	out.print("</ul>");
	out.print("</div>");
	out.print("</div>");
}
%>
	<h1 align="center">
	<%
	//選んだクラス名表示
	ServletContext context = this.getServletContext();
	String path = context.getRealPath("/WEB-INF/connect.properties");
	
	InputStream in = new FileInputStream(path);
	Properties properties = new Properties();
	properties.load(in);
	in.close();
	
	HttpSession sess = request.getSession(true);
	Object sel_class = sess.getAttribute("sel_class");
	Class.forName("com.mysql.jdbc.Driver");
	Connection conn = null;
	String url = properties.getProperty("key1");
	String user = properties.getProperty("key2");
	String password = properties.getProperty("key3");
	conn = DriverManager.getConnection(url, user, password);
	Statement stmt = conn.createStatement();
	String sql = "SELECT * FROM class WHERE class_id = "+sel_class;
	ResultSet rs = stmt.executeQuery(sql);
	while(rs.next()){
		out.print(rs.getString("class_name"));
	}
	rs.close();
	stmt.close();
	conn.close();
	%>
	</h1>
	<div class="container">
		<div align="center">
			<table class="table table-bordered table-striped" style="font-size: large">
			  <tr class="success">
			    <th>&nbsp;</th>
			    <th>&nbsp;</th>
			    <th>月曜日</th>
			    <th>火曜日</th>
			    <th>水曜日</th>
			    <th>木曜日</th>
			    <th>金曜日</th>
			 
			  </tr>
			  
			  <tr>
			    <td rowspan="2">１時限<br>(9:15 - 10:45)</td>
			    <td>科目名</td>
			    <td>${ requestScope.mo1 }</td>
			    <td>${ requestScope.tu1 }</td>
			    <td>${ requestScope.we1 }</td>
			    <td>${ requestScope.th1 }</td>
			    <td>${ requestScope.fr1 }</td>
			  </tr>
			  <tr class="success">
			    <td>教室</td>
			    <td>${ requestScope.mo1r }</td>
			    <td>${ requestScope.tu1r }</td>
			    <td>${ requestScope.we1r }</td>
			    <td>${ requestScope.th1r }</td>
			    <td>${ requestScope.fr1r }</td>
			  </tr>
			  <tr>
			    <td rowspan="2">２時限<br>(11:00 - 12:30)</td>
			    <td>科目名</td>
			    <td>${ requestScope.mo2 }</td>
			    <td>${ requestScope.tu2 }</td>
			    <td>${ requestScope.we2 }</td>
			    <td>${ requestScope.th2 }</td>
			    <td>${ requestScope.fr2 }</td>
			    
			    </tr>
			  <tr class="success">
			    <td>教室</td>
			    <td>${ requestScope.mo2r }</td>
			    <td>${ requestScope.tu2r }</td>
			    <td>${ requestScope.we2r }</td>
			    <td>${ requestScope.th2r }</td>
			    <td>${ requestScope.fr2r }</td>
			  </tr>
			  <tr>
			    <td rowspan="2">３時限<br>(13:10 - 14:00)</td>
			    <td>科目名</td>
			    <td>${ requestScope.mo3 }</td>
			    <td>${ requestScope.tu3 }</td>
			    <td>${ requestScope.we3 }</td>
			    <td>${ requestScope.th3 }</td>
			    <td>${ requestScope.fr3 }</td>
			    
			    </tr>
			  <tr class="success">
			    <td>教室</td>
			    <td>${ requestScope.mo3r }</td>
			    <td>${ requestScope.tu3r }</td>
			    <td>${ requestScope.we3r }</td>
			    <td>${ requestScope.th3r }</td>
			    <td>${ requestScope.fr3r }</td>
			  </tr>
			  <tr>
			    <td rowspan="2">４時限<br>(15:15 - 16:45)</td>
			    <td>科目名</td>
			    <td>${ requestScope.mo4 }</td>
			    <td>${ requestScope.tu4 }</td>
			    <td>${ requestScope.we4 }</td>
			    <td>${ requestScope.th4 }</td>
			    <td>${ requestScope.fr4 }</td>
			    
			    </tr>
			  <tr class="success">
			    <td>教室</td>
			    <td>${ requestScope.mo4r }</td>
			    <td>${ requestScope.tu4r }</td>
			    <td>${ requestScope.we4r }</td>
			    <td>${ requestScope.th4r }</td>
			    <td>${ requestScope.fr4r }</td>
			    
			  </tr>
			  
			</table>
		</div>
	</div>
	<br>
<h3 align="center">＜お知らせ＞</h3>
<br>
<div class="container">
	<div class="col-md-6 col-md-offset-3">
		<table class="table table-bordered">
			<tr><td align="center"><%
			
			//時間割変更等のお知らせ表示
			sel_class = sess.getAttribute("sel_class");
			Class.forName("com.mysql.jdbc.Driver");
			conn = null;
			url = properties.getProperty("key1");
			user = properties.getProperty("key2");
			password = properties.getProperty("key3");
			conn = DriverManager.getConnection(url, user, password);
			stmt = conn.createStatement();
			sql = "SELECT * FROM timetable_info WHERE class_id = "+sel_class;
			rs = stmt.executeQuery(sql);
			while(rs.next()){
				out.print("<p><font size=\"4\">"+rs.getString("news_content")+"</font></p>");
			}
			rs.close();
			stmt.close();
			conn.close();
			%></td></tr>
		</table>
	</div>
</div>

<br>
  
  

	<div align="center">
	<%
		if(login==null){
			out.print("<a href=\"TimetableClassSelection.jsp\" class=\"btn btn-lg btn-danger\"><i class=\"glyphicon glyphicon-arrow-left\"><br>クラス選択へ戻る</i></a>");
		}
		%>
		<a href="index.jsp" class="btn btn-lg btn-danger"><i class="glyphicon glyphicon-home"><br>トップへ</i></a>
	</div>
</body>
</html>